package com.e3.web.core.server;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import com.e3.core.base.ServiceLocator;
import com.e3.core.cache.CacheManager;
import com.e3.core.life.ApplicationLifecycleManager;
import com.e3.sysmg.security.server.UserHelper;

public class SystemInitializationListener implements ServletContextListener {

	public void contextDestroyed(ServletContextEvent arg0) {

	}

	public void contextInitialized(ServletContextEvent arg0) {
		initApplication();
		startApplication();
	}
	
	private void initApplication(){
		System.getProperties().put("logback.configurationFile","/conf/logback.xml");
		ServiceLocator.init();
		ApplicationLifecycleManager.init();
		CacheManager.init();
		UserHelper.init();
	}
	
	private void startApplication(){
//		System.err.println("begin to start cache....");
		ApplicationLifecycleManager.start();
	}

}
